<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        i{
            font-style: normal;
            color: red;
            font-size: 20px;
        }
        html,body{
            height: 100%;
        }
        #app{
            /* height: 100%; */
            width: 100%;
            position: absolute;
            bottom: 0;
        }
        #app .bx{
            width: 92%;
            /* background-color: antiquewhite; */
            margin: auto;
            height: 92%;
            margin-top: 4%;
            
        }
        #app .bx .title{
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
        }
        #app .bx .list{
            height: 120px;
        }
        #app .bx .list img{
            width: 100px;
            height: 100px;
            float: left;
            margin: 0 5px;
        }
        #app .bx .list .price{
            margin-top: 60px;
            display: flex;
            justify-content: space-between;
        }
        #app .bx .list .price span{
            display: inline-block;
            width: 16px;
            height: 16px;
            text-align: center;
            line-height: 14px;
            background-color: lightskyblue;
            color: white;
            border-radius: 50%;
        }
        #app .bx .list .price span:nth-child(2){
            color: black;
            background-color: white;
        }
        .cls{
            width: 100%;
            height: 100px;
            text-align: center;
            line-height: 100px;
        }
        #app .bx .summary{
            display: flex;
            justify-content: space-between;
            background-color: gray;
            height: 40px;
            line-height: 40px;
            width: 100%;
            
        }
        #app .bx .summary span:nth-child(2){
            background-color: lightgreen;
            color: white;
            height: 6px;
            padding: 10px;
            margin-top: 5px;
            line-height: 6px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="bx">
            <div class="title">
                <h3>已选商品</h3>
                <span @click="clean">清空</span>
            </div>
            <div v-if="list.length!==0">
                <div class="list" v-for="(item,index) in list">
                    <img :src="item.pic" >
                    <h4>{{item.name}}</h4>
                    <div class="price">
                        <i>￥{{item.price}}</i>
                        <div>
                            <span @click="sub(item)">-</span>
                            <span>{{item.count}}</span>
                            <span @click="add(item)">+</span>
                        </div>
                    </div>
                </div> 
            </div>
            <div v-else class="cls">购物车空空如也,去逛逛!</div>
            <div class="summary">
                <span>总数:{{totalCount}} 总价:{{totalPrice}} </span>
                <span>去结算</span>
            </div>
        </div>
    </div>
</body>
</html>
<script src="./vue-2.5.21.js"></script>
<script src="./购物车.js"></script>